package org.clockworkmages.games.anno1186.model.effect;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;

import org.clockworkmages.games.anno1186.GameBeansContext;
import org.clockworkmages.games.anno1186.GameStateService;
import org.clockworkmages.games.anno1186.model.GameObject;

public class Condition
		extends GameObject {

	private List<Effect> effects = new ArrayList<Effect>();

	private String name;

	private String description;

	/**
	 * Combat-only conditions are automatically removed at the end of the
	 * combat.
	 */
	private boolean combatOnly = false;

	/**
	 * Interval says how often the Condition's affects should occur. This is
	 * typically important for confition that affect base statistics (e.g.
	 * damage or regenerate health).
	 */
	private Long interval;

	public ConditionStatus makeStatus(int level, long validUntil) {
		long gameTime = GameBeansContext.getBean(GameStateService.class)
				.getGameState().getTime();
		ConditionStatus conditionStatus = new ConditionStatus(level,
				validUntil, gameTime);
		return conditionStatus;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@XmlElement(name = "effect")
	public List<Effect> getEffects() {
		return effects;
	}

	public void setEffects(List<Effect> effects) {
		this.effects = effects;
	}

	public boolean isCombatOnly() {
		return combatOnly;
	}

	public void setCombatOnly(boolean combatOnly) {
		this.combatOnly = combatOnly;
	}

	public Long getInterval() {
		return interval;
	}

	public void setInterval(Long interval) {
		this.interval = interval;
	}

}
